package com.lanchetech.user.controller;

import com.lanchetech.bean.response.ResultData;
import com.lanchetech.bean.vo.StoreDetailVO;
import com.lanchetech.entity.MsgUser;
import com.lanchetech.entity.TenantConfig;
import com.lanchetech.entity.User;
import com.lanchetech.user.service.StoreService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.security.core.annotation.AuthenticationPrincipal;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

@Api(value = "店铺接口", tags = "店铺接口(开放接口)")
@RequestMapping("/api/store")
@RestController
public class StoreController {

    @Autowired
    StoreService storeService;

    @ApiOperation("获取店铺首页信息")
    @GetMapping("/getStoreDetail")
    public ResultData<StoreDetailVO> getStoreDetail(@AuthenticationPrincipal User user, @RequestParam("tenantId") Long tenantId) {
        return storeService.getStoreDetail(user, tenantId);
    }

    @ApiOperation("获取店铺客服信息")
    @GetMapping("/getStoreMsgUser")
    public ResultData<MsgUser> getStoreMsgUser(@RequestParam("tenantId") Long tenantId, @RequestParam("msgUserId") Long msgUserId) {
        return storeService.getStoreMsgUser(tenantId, msgUserId);
    }

    @ApiOperation("获取指定店铺配置")
    @GetMapping("/getTenantConfig")
    public ResultData<TenantConfig> getTenantConfig(@RequestParam("tenantId") Long tenantId, @RequestParam("name") String name) {
        return storeService.getTenantConfig(tenantId, name);
    }
}
